package com.glhtgyxy.biyesheji.Service;

import com.glhtgyxy.biyesheji.Mapper.dlzcMapper;
import com.glhtgyxy.biyesheji.Pojo.merchant;
import com.glhtgyxy.biyesheji.Pojo.user;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Collection;

@Service
public class dlzcService {

    @Autowired
    dlzcMapper mapper;

    public ArrayList<user> dlzc(String  useraccount , String  password) {
        ArrayList<user> users = mapper.dl(useraccount,password);
        if (!CollectionUtils.isEmpty(users)){
            return users;
        }else {
            int a = mapper.zc(useraccount,password);
            if (a>0){
                return mapper.dl(useraccount,password);
            }
            else {
                System.out.println("注册异常！");
            }
        }
        return null;

    }

    public ArrayList<merchant> sjdl(String  useraccount , String  password) {
        ArrayList<merchant> users = mapper.sjdl(useraccount,password);
        if (!CollectionUtils.isEmpty(users)){
            return users;
        }else {
            int a = mapper.sjzc(useraccount,password);
            if (a>0){
                return mapper.sjdl(useraccount,password);
            }
            else {
                System.out.println("注册异常！");
            }
        }
        return null;

    }

    public  String  idfindusername(int id ){
        user a = mapper.idfindusername(id);
        return a.getUsername();
    }

    public  String  idfindmerchant(int id ){
        merchant a = mapper.idfindmerchant(id);
        return a.getMerchantname();
    }
}
